<%@ page import="com.wuming.caiwu.security.SecurityHander" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>管理余额变动</title>
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/formSelects-v4.css">
    <style>
        .query-condition {
            margin-top: 15px;
        }
    </style>
</head>
<body style="background-color: #f0f2f5;">
<div style="padding: 15px;margin: 15px;background-color: #fff;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>余额变动查询</legend>
    </fieldset>
    <form id="queryForm" class="layui-form" action="">
        <div class="" style="margin-top: 15px;">
            <div class="layui-row query-condition">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">会员名</label>

                        <div class="layui-input-inline">
                            <input type="text" name="memberName" id="memberName" placeholder=""
                                   autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="layui-row query-condition" style="padding: 9px 15px;margin-bottom: 20px;">
        <button name="btnQuery" class="layui-btn layui-btn-normal" data-type="reload">查询搜索</button>
    </div>

    <table class="layui-hide" id="studentsInfo" lay-filter="demo" lay-data="{height: 'full-200'}">
    </table>
</div>

<script type="text/html" id="statusTpl">
    {{#  if(d.status == 0){ }}
    <span>待审核</span>
    {{#  } else if(d.status == 1){ }}
    <span>审核通过</span>
    {{#  }  }}
</script>


<script type="text/html" id="barDemo">
    {{#  if(d.status == 0){ }}
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="audit">审核通过</a>
    {{#  }  }}
</script>

<script src="${allServerPath}static/layui/layui/layui.js"></script>
<script>
    layui.config({
        base: '${allServerPath}static/layui/build/js/'
    }).extend({
        formSelects: 'formSelects-v4.min'
    }).use(['table', 'jquery'], function () {
        var table = layui.table,
            $ = layui.jquery;

        table.render({ //其它参数在此省略
            elem: '#studentsInfo'
//            , height: 500
            , url: '${allServerPath}web/balancerecord/list.htmls?t=' + Date.parse(new Date())
            , cols: [[ //表头
                {type: 'checkbox'}
                , {field: 'id', align: 'center', title: 'ID', width: 80}
                , {field: 'memberName', title: '会员名', align: 'center', width: 160}
                , {field: 'oldBalance', title: '原余额', align: 'center', width: 200}
                , {field: 'newBalance', title: '新余额', align: 'center', width: 200}
                , {field: 'userId', title: '操作人ID', align: 'center', width: 200}
                , {field: 'status', title: '状态', align: 'center', width: 200,templet: '#statusTpl'}
                , {fixed: 'right', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]],
            id: 'studentContent',
            where: {
            }, //如果无需传递额外参数，可不加该参数
            method: 'get', //如果无需自定义HTTP类型，可不加该参数
            page: true,
            limits: [10, 20, 30, 50, 100, 200],
            limit: 10,
            request: {
                pageName: 'pageIndex', //页码的参数名称，默认：page
                limitName: 'pageSize'
            }, //如果无需自定义请求参数，可不加该参数
            response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'message' //状态信息的字段名称，默认：msg
                , countName: 'total' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            }, //如果无需自定义数据响应名称，可不加该参数
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            },
            text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
        });


        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'audit') {
                layer.open({
                    type: 2,
                    title: '审核余额变动',
                    maxmin: true,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['1000px', '580px'],
                    end: function () {
                        table.reload('studentContent', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                        });
                    },
                    content: '${allServerPath}web/balancerecord/editUmsMemberBalanceRecord/' + data.id + '.htmls'
                });
            }
        });

        $('button[name="btnQuery"]').on('click', function () {
            table.reload('studentContent', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    "memberName": $('#memberName').val()
                }
            });
        });

    });

</script>
</body>
</html>
